package com.zxr.service.impl;

import com.zxr.commen.Pageing;
import com.zxr.commen.PageingFinder;
import com.zxr.dao.AdministratorDao;
import com.zxr.service.AdministratorService;
import com.zxr.vo.Administrator;
import com.zxr.vo.Equipmentclass;
import com.zxr.vo.Sysuserrole;

public class AdministratorServiceImpl implements AdministratorService {

	public AdministratorDao administratorDao;
	
	public PageingFinder<Administrator> pageAdministrator(Pageing page) {
		PageingFinder<Administrator> pageingFinder=new PageingFinder<Administrator>();
		pageingFinder.setDataList(administratorDao.pageAdministrator(page));
		pageingFinder.setRowCount(administratorDao.pageAdministratorCount(page));
		return pageingFinder;
	}

	public Long pageAdministratorCount(Pageing page) {
		return null;
	}

	public void addAdministrator(Administrator administrator,String roleid[]) {
		administratorDao.addAdministrator(administrator);
		
		int userid=administratorDao.finduseridBy(administrator);
		System.out.println("+++++"+userid);
		if(null != roleid){
			for(int i = 0; i < roleid.length; i++){
				Sysuserrole sysuserrole = new Sysuserrole();
				sysuserrole.setUserid(userid);
			
				sysuserrole.setRoleid(roleid[i]);
				System.out.println("+++++"+roleid[i]);
				administratorDao.addUserRole(sysuserrole);
			}
			}
	}

	public void deleteAdministrator(int userid) {
		administratorDao.deleteAdministrator(userid);
	}

	public void updateAdministrator(Administrator administrator) {
		administratorDao.updateAdministrator(administrator);
	}

	public Administrator findAdministratorById(int userid) {
		return administratorDao.findAdministratorById(userid);
	}

	public void setAdministratorDao(AdministratorDao administratorDao) {
		this.administratorDao = administratorDao;
	}

	
 
}
